//
//  SetupViewController.m
//  片刻
//
//  Created by lanou3g on 15/6/3.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "SetupViewController.h"
#import "SetupNameModel.h"
#import "GeneralViewController.h"
@interface SetupViewController ()
@property (nonatomic,retain) NSMutableArray *mutableArr;
@property (nonatomic,retain) NSArray *arr;
@end

@implementation SetupViewController
-(void)dealloc{
    _mutableArr = nil;
    _arr     = nil;
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
//    UIButton *button = [UIButton buttonWithType:(UIButtonTypeSystem)];
//    button.frame = CGRectMake(10, 100, 30, 30);
//    button.backgroundColor = [UIColor yellowColor];
//    [button addTarget:self action:@selector(handleButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
//    UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:self.rootRightVC];
//    navi.navigationBar.hidden = YES;
//    [self.view addSubview:button];
    self.naviLabel.text =@"设置";
    
    [self createSetupArr];
    [self createTableView];
    
    
}
-(void)createTableView
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 70, self.view.frame.size.width, self.view.frame.size.height-70) style:(UITableViewStylePlain)];
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"asd"];
    [self.view addSubview:tableView];
    
    [tableView release];
    
}
-(void)createSetupArr
{
    self.mutableArr = [NSMutableArray array];
    NSArray *arr = @[@[@"通用设置",@"GeneralViewController"],@[@"推荐片刻",@""],@[@"监测新版本",@""],@[@"关于片刻",@"AbutViewController"],@[@"使用指南",@""],@[@"建议反馈",@""],@[@"常见问题",@""],@[@"退出当前账号",@""],@[@"退出应用",@""]];
    for (NSArray *modelArr in arr) {
        SetupNameModel *model = [[SetupNameModel alloc] init];
        model.disName = modelArr[0];
        model.className = modelArr[1];
        [self.mutableArr addObject:model];
        
        [model release];
    }

    
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
        return [self.mutableArr count];

   
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SetupNameModel *model = self.mutableArr[indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"asd" forIndexPath:indexPath];
    cell.textLabel.text = [NSString stringWithFormat:@"%@",model.disName];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    SetupNameModel *model = self.mutableArr[indexPath.row];
    
    [self addViewWith:model];
}

-(void)addViewWith:(SetupNameModel *)index
{
    [self.navigationController pushViewController:[[NSClassFromString(index.className) alloc] init] animated:YES];
    
}

//-(void)handleButtonAction:(UIButton *)button
//{
//    SetupTableViewController *che = [[SetupTableViewController alloc]init];
//    [self.navigationController pushViewController:che animated:YES];
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
